var temp = {
    error:'',
    data:'',
    success:''
};

let con = require('./sql_main');

con.query('SELECT * FROM temp_table',function(err,rows,fields){

    // let temp = {
    //     error:'',
    //     data:'',
    //     success:''
    // };
    console.log(rows);
    !err?temp.success=true:temp.success=false;
    temp.data = rows;
    temp.error = err;

    // module.exports = temp;

    // console.log(rows.constructor);
    // console.log(typeof(rows));
    // console.log(err);
    // console.log(fields);
});

//连接完毕后，关闭连接
    con.end();

/**   添加
 *var  addSql = 'INSERT INTO websites(Id,name,url,alexa,country) VALUES(0,?,?,?,?)';
 var  addSqlParams = ['菜鸟工具', 'https://c.runoob.com','23453', 'CN'];
 //增
 connection.query(addSql,addSqlParams,function (err, result) {
        if(err){
         console.log('[INSERT ERROR] - ',err.message);
         return;
        }

       console.log('--------------------------INSERT----------------------------');
       //console.log('INSERT ID:',result.insertId);
       console.log('INSERT ID:',result);
       console.log('-----------------------------------------------------------------\n\n');
});

 *   更新(修改)
 *
 * var modSql = 'UPDATE websites SET name = ?,url = ? WHERE Id = ?';
 var modSqlParams = ['菜鸟移动站', 'https://m.runoob.com',6];
 //改
 connection.query(modSql,modSqlParams,function (err, result) {
   if(err){
         console.log('[UPDATE ERROR] - ',err.message);
         return;
   }
  console.log('--------------------------UPDATE----------------------------');
  console.log('UPDATE affectedRows',result.affectedRows);
  console.log('-----------------------------------------------------------------\n\n');
});

 *    删除
 *
 *    var delSql = 'DELETE FROM websites where id=6';
 /
 connection.query(delSql,function (err, result) {
        if(err){
          console.log('[DELETE ERROR] - ',err.message);
          return;
        }

       console.log('--------------------------DELETE----------------------------');
       console.log('DELETE affectedRows',result.affectedRows);
       console.log('-----------------------------------------------------------------\n\n');
});
 *
 *
 *
 *
 */

module.exports = temp;
